package cn.swh.guguanjia.mapper;

import cn.swh.guguanjia.entity.SysRole;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

@org.apache.ibatis.annotations.Mapper
public interface SysRoleMapper extends Mapper<SysRole> {
    @SelectProvider(type = SysRoleProvider.class, method = "selectPage")
    List<SysRole> selectPage(Map<String, Object> map);


    @DeleteProvider(type = SysRoleProvider.class, method = "deleteBatch")
    int deleteBatch(@Param("rid") long rid, @Param("ids") long[] ids);

    @InsertProvider(type = SysRoleProvider.class, method = "insertBatch")
    int insertBatch(@Param("rid") long rid, @Param("cids") List<Long> cids);

    //   删除原已选资源
    @Delete("delete from sys_role_resource where role_id=#{rid}")
    int deleteById(long rid);

    //    批量插入已选资源
    @InsertProvider(type = SysRoleProvider.class, method = "insertRoleResources")
    int insertRoleResources(@Param("rid") long rid, @Param("resources") List<Integer> resources);

    //    删除原已选公司
    @Delete("delete from sys_role_office where role_id=#{rid}")
    int deleteOfficeById(long rid);

    //    批量插入已选公司
    @InsertProvider(type = SysRoleProvider.class, method = "insertRoleOffices")
    int insertRoleOffices(@Param("rid") long rid, @Param("offices") List<Integer> offices);

}